<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        #div1 {width: 100px; height: 100px; background-color: #cdcdcd; position: absolute; left: 0;}
    </style>
</head>
<body>
<script>
    window.onload = function(){
        var oDiv = document.getElementById('div1');
        var oBtn1 = document.getElementById('btn1');
        var oBtn2 = document.getElementById('btn2');

        oBtn1.onclick = function() {
            timer = setInterval(function(){
                oDiv.style.left = oDiv.offsetLeft + 5 + 'px';
            },30);
        };
        oBtn2.onclick = function() {
            clearInterval(timer);
        }
    };
</script>

<input id="btn1" type="button" value="向右滚动">
<input id="btn2" type="button" value="停止滚动">
<div id="div1"></div>
</body>
</html>